<?php

namespace app\common\validate;

use think\Validate;

class Login extends Validate
{
	protected $rule = [
		'password' => 'require|length:5,21|regex:/^(?=.*\d)(?=.*[a-zA-Z]).{6,20}$/',
		'mobile' => ['require','regex' => '/^1[3|4|5|7|8][0-9]\d{4,8}$/i'],
		'code' => 'require'
	];
	protected $message = [
		'mobile.require' => '手机号码不能为空',
		'mobile.regex' => '手机号码格式错误',
		'mobile.unique' => '手机号码已存在',
		'password.require' => '密码不能为空',
		'password.regex' => '密码长度为6-20位，必须包含数字和字母（区分大小写）',
		'code.require' => '验证码不能为空',
	];
	protected $scene = [
		'password_login' =>  ['password'],
		'register' => ['mobile' => 'require', 'password' => 'require', 'code'],
		'register_add' => ['mobile' => ['require','regex' => '/^1[3|4|5|7|8][0-9]\d{4,8}$/i'],'password'],
		'retrieve_password' => ['mobile' => ['require','regex' => '/^1[3|4|5|7|8][0-9]\d{4,8}$/i'],'password'],
	];
}